/**
 * 
 */
package com.ofek.eventos.net.lks;

import java.util.ArrayList;






/**
 * @author Ofek
 *
 */
public interface IDistributeableDatabaseHandle<IDT,IT>{
	/**
	 * return the current known version of the item with the same id as represented by id.
	 * @param id
	 * @return null if item not exists, oterwise the current known version
	 */
	Long getVersion(IDT id);

	/**
	 * 
	 * @param id
	 * @param item - if null remove
	 * @param version - if 0 add else update
	 */
	void addChangePending(IDT id,IT item,long version);

	/**
	 * 
	 */
	void lock();
	/**
	 * 
	 */
	void unlock();
	/**
	 * @return
	 */
	ArrayList<ItemVersion<IDT, IT>> getAllPending();
	/**
	 * @return
	 */
	ArrayList<ItemVersion<IDT, IT>> getAllSynced();
	/**
	 * @param syncIn
	 * @return
	 */
	ArrayList<ItemVersion<IDT, IT>> getPendings(Sync<IDT, IT> syncIn);
	/**
	 * @param newBundles
	 * @return 
	 */
	LastKnownHandler<IDT> syncItems(Sync<IDT, IT> syncIn);
	/**
	 * @return
	 */
	LastKnownHandler<IDT> getLastKnowns();

	/**
	 * 
	 */
	void close();

	public boolean addDistributedDatabaseListener(final DistributedDatabaseListener<IDT, IT> l);

	public boolean removeDistributedDatabaseListener(final DistributedDatabaseListener<IDT, IT> o);


}
